package com.ljh.tr.util;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
	
	/**
	 * @param str 需要加密的  明文
	 * @return 
	 * @desc 数据加密
	 * @time 2017-8-2上午10:42:37
	 */
	public static String getMD5(String str){
		MessageDigest md5;
		try {
			md5 = MessageDigest.getInstance("MD5");
			return new BigInteger(1, md5.digest(str.getBytes("UTF-8"))).toString(16);
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return null;
	}
	public static void main(String[] args) {
		//17e62166fc8586dfa4d1bc0e1742c08b
		System.out.println(getMD5("43"));
	}
}
